package com.ahui.util;

import com.aspose.words.Document;
import com.aspose.words.SaveFormat;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.FileOutputStream;

/**
 * @author : ph.li
 * @date : 2023/7/30 14:16
 */
@Slf4j
public class WordUtil {

    public static boolean wordToPdf(String filePath, String pdfPath) {
        if (!LicenseUtil.getLicense()) {
            log.warn("word转pdf获取License失败!");
            return false;
        }

        File file = new File(pdfPath);
        try (FileOutputStream os = new FileOutputStream(file)) {
            Document doc = new Document(filePath);
            doc.save(os, SaveFormat.PDF);
        } catch (Exception e) {
            log.error("word [{}] 转pdf失败", filePath, e);
        }

        return false;
    }

}
